This is actually a very difficult thing to do.
Looks like the only js library that can do it is this:
Here's an example of it's use from C2 with the browser object.
https://www.dropbox.com/s/t267l8lhl7tsc ... .capx?dl=1
First it loads the needed libraries and call the "ready" function when it's done.
Then to get a image to save it snapshots the canvas. You could use the canvas object to get image data as well.
Finally it generates the file and uses the browser object to download it.
It basically follows the examples on their site and at the very least gives you a starting point to play around with. Also I won't be making a plugin for this.