loops through images to write