Reversed height and width in writing loop. This makes the image come out the right way up.