Optical loss mechanisms in magnesium-doped lithium niobate crystals in the 300 to 2950 nm wavelength range