The key is the canvas instantiation. The constructor takes a file-like object and writes into it. You might have noticed that the code is heavily inspired by this tutorial. The only difference is the creation of canvas.

That's it. See? I said it was easy. You can run the dev_appserver or upload it to Google in order to see the results.