Formation of electron bunches for harmonic cascade x-ray free electron lasers