Fix write_varlen_number for Python 3
repair: More Python 3 fixes