patched code to improve photo viewer performance, especially for very large photos