Flame-capturing Technique. I. Adaptation to Gas Expansion