Moving logic into controller
Merging Clark's changes for canvas-to-image transfer