write and delete images from file directory