improve to_big_endian_binary function