Forming the light into pulses