Scattering of coherent pulses on a two-level system—single-photon generation