def getint(data, offset, intsize):
  """ Retrieve an integer (big-endian) and new offset from the current offset """
  value = 0
  while intsize > 0:
    value = (value << 8) + data[offset]
    offset += 1
    intsize -= 1
  return value, offset