  We experimentally demonstrate optimal storage and retrieval of light pulses
of arbitrary shape in atomic ensembles. By shaping auxiliary control pulses, we
attain efficiencies approaching the fundamental limit and achieve precise
retrieval into any predetermined temporal profile. Our techniques, demonstrated
in warm Rb vapor, are applicable to a wide range of systems and protocols. As
an example, we present their potential application to the creation of optical
time-bin qubits and to controlled partial retrieval.
