The effect of an external transverse magnetic field on ionization injection of electrons in a laser wakefield accelerator (LWFA) is investigated by theoretical analysis and particle-in-cell simulations. On application of a few tens of Tesla magnetic field, both the electron trapping condition and the wakefield structure changes significantly such that injection occurs over a shorter distance and at an enhanced rate. Furthermore, beam loading is compensated for, as a result of the intrinsic trapezoidal-shaped longitudinal charge density profile of injected electrons. The nonlinear ionization injection and consequent compensation of beam loading lead to a reduction in the energy spread and an enhancement of both the charge and final peak energy of the electron beam from a LWFA immersed in the magnetic field.