Writing magnetic memory with ultrashort light pulses