Multiple modifications

Major changes to index.html demo site. Added a check for image.complete
in initial function. Added simple scale function. Moved some
functionality to private utility functions.