Use internal function for hex encoding, sprintf gives odd results