Fixes to image viewer code