Black holes in electromagnetic fields and the second law of black hole physics