def readAsInteger(fs, n):
    """
    Reads n bytes and returns them as an integer.
    """
    b = fs.read(n)
    if len(b) != n:
        raise Exception('Can not read {} bytes only {}'.format(n, len(b)))
    try:
        r = int(b)
    except ValueError:
        raise Exception('Can not determine integer RP66 version number from {}'.format(b))
    return r