Formation of virtual cathodes and microwave generation in relativistic electron beams