Vacuum decay, gravitational waves and magnetic fields in the early universe