var image = canvas.toDataURL();
var aDownloadLink = document.createElement('a'); // create a hidden link
aDownloadLink.download = 'canvas_image.png'; // add here the name of the file
aDownloadLink.href = image; // add the link href
aDownloadLink.click(); // click the link