SIMULATIONS OF EMERGING MAGNETIC FLUX. I. THE FORMATION OF STABLE CORONAL FLUX ROPES