cleaned up display_image() by creating a separate generate_image(). the goal is that this will be usable from outside an image request