def map_image(orig_image, mask_map):
    """Map the image pixels for a single image, returning a new image"""
    orig_image_pixels = orig_image.load()

    new_image = orig_image
    new_image_pixels = new_image.load()
    for i in range(orig_image.size[0]):
        for j in range(orig_image.size[1]):
            new_image_pixels[i, j] = mask_map[orig_image_pixels[i, j]]
    return new_image