'int and long values are written using variable-length, zig-zag coding.'

def write_long(self, datum):

    datum = ((datum << 1) ^ (datum >> 63))
    while ((datum & (~ 127)) != 0):
        self.write(chr(((datum & 127) | 128)))
        datum >>= 7
    self.write(chr(datum))
