import png

width = 2400
height = 1000
img = []

for y in range(height):
    row = ()
    for x in range(int(width/3)):
        row = row + (255, 0, 0)
    for x in range(int(width/3)):
        row = row + (0, 255, 0)
    for x in range(int(width/3)):
        row = row + (0, 0, 255)
    img.append(row)

with open('gradient.png', 'wb') as f:
    w = png.Writer(width, height, greyscale=False)
    w.write(f, img)

