Dynamics of slow-light formation