def flip_y(im):
    """mirrors an image over the x axis."""
    source_pix = im.load()
    im = im.copy()
    dest_pix = im.load()
    width, height = im.size
    for i in range(width):
        for j in range(height):
            dest_pix[i,j] = source_pix[i, height-j-1]
    return im