Ensure images are always resized to canvas size

This change ensures that images are always resized to canvas size. It greatly improves JS code responsiveness when working with larger images. Also file loading code is now common for JS and GL.