Making create_thumbnails() more resistant to errors