def MPInt(value):
    """Encode a multiple precision integer value"""
    l = value.bit_length()
    l = l // 8 + 1 if value != 0 and l % 8 == 0 else (l + 7) // 8
    return l.to_bytes(4, 'big') + value.to_bytes(l, 'big', signed=True)
