Code refactoring to avoid some code duplication.
Simple image viewer.