rewrite write_longlong (optimized for 64bits and smaller values)