Remote preparation of an atomic quantum memory