wrote function to do one iteration
wrote output image function