Optimized control of generation of few cycle pulses by molecular modulation