fixed problems with images and output the key in a txt file