write images to images directory