I'm surprised nobody chimed in here. WordPress has this sort of thing built in. Just create an attachment.php file in your theme, and it will be used when you display images as a post.
When you upload an image, there's an option to link to the image or link to it as a page. The image link is direct, but the page link gives a link to a WordPress page containing the attachment. This is because every upload gets its own "post" of sorts. When you link to it this way, it shows that single post. But it uses the attachment.php file in the theme to do it. So copy your theme's index.php to attachment.php and customize that. Done.