Writes the integer <v> packed to <f>.

def write_packed_int(f, v):
    """ Writes the integer <v> packed to <f>. """
    if v == 0:
        f.write("\0")
    while v > 0:
        c = v & 127
        v >>= 7
        if v != 0:
            c = c | 128
        f.write(chr(c))