'Numbers of 8 bytes are signed integers when they refer to numbers, but unsigned otherwise.'

def getSizedInteger(self, data, byteSize, as_number=False):

    result = 0
    if (byteSize == 1):
        result = unpack('>B', data)[0]
    elif (byteSize == 2):
        result = unpack('>H', data)[0]
    elif (byteSize == 4):
        result = unpack('>L', data)[0]
    elif (byteSize == 8):
        if as_number:
            result = unpack('>q', data)[0]
        else:
            result = unpack('>Q', data)[0]
    elif (byteSize <= 16):
        result = 0
        if hasattr(int, 'from_bytes'):
            result = int.from_bytes(data, 'big')
        else:
            for byte in data:
                result = ((result << 8) | unpack('>B', byte)[0])
    else:
        raise InvalidPlistException('Encountered    integer    longer    than    16    bytes.')
    return result
