Reducing the mode-mismatch noises in atom–light interactions via optimization of the temporal waveform