Gain in spatially varying optical fields: Applications to high emittance beams and gas dielectric FEL's