def _int_to_bytes(integer, endian = 'little'):
    """Convert int to bytes object without specifing size"""
    size = 1
    while 1<<(8*size) <= integer:
        size += 1

    return integer.to_bytes(size, endian)