Efficient multimode quantum memory based on photon echo in an optimal QED cavity