Move tons of stuff out of menus.js

Now menus.js is pretty much just a data structure.
Make image transformations work on pasted images

Sometimes selection.canvas is an Image, but apply_image_transformation
assumed it was always a Canvas