def getIndex(x:int, y:int, width:int):
    """Return the internal picture index of a given pixel, given xy position and the width of the image. Indexing starts at 1, 1."""
    #Original
    #return 4 * (width * (y - 1) + x) - 1
    # Fixed python indexing
    return 4 * (width * (y - 1) + x) - 2