Generally, flames out the pipe mean unburnt fuel in the exhaust system being ignited downstream. Often it is a lean condition, your engine doesn't ignite the fuel and the unburnt charge ends up being ignited in the exhaust system by the next hot exhaust stream from the next cylinder (backfire). When you downshift (or upshift) your throttle plate makes a sudden change that often isn't reacted to fast enough by the fuel sytem (carburetor or FI). The sudden change can cause an overly lean (usually) or rich condition that causes the backfire to happen. So you may be ok on your mixture running normally, but can have a backfire during very fast throttle position changes.
