def add_pixel(img, index, size, pixel):
    """Add a pixel to the image at (index % size, index / size).

    :param Image.Image img: image to alter
    :param int index: index of the byte
    :param int size: width of the image
    :param int pixel: pixel value to set
    """
    img.putpixel((index % size, index // size), pixel)
