Пример с Promise.
JSFiddle
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
function loadImage(src){
return new Promise(function(resolve){
var pic = new Image();
pic.onload = function(){
canvas.width = pic.width;
canvas.height = pic.height;
resolve(pic);
}
pic.crossOrigin = 'anonymous';
pic.src = src;
});
}
function drawImage(pic){
context.drawImage(pic, 0, 0, pic.width, pic.height);
context.fillStyle = "black";
context.font = 'bold 30px sans-serif';
context.fillText("Autor Famyly", 290, 235);
return canvas.toDataURL("image/png");
}
function saveImage(dataURL) {
var a = document.createElement('a');
a.href = dataURL;
a.download = 'Certificate';
a.click();
};
loadImage('http://i.imgur.com/fHyEMsl.jpg').then(drawImage).then(saveImage);