ImageViewer: fix calculating pixel size and some other bugs.