Moved and improved create_jpeg function here
dev of get_image request