Ok, so I discovered that the problem only occurred for images larger than 256x256. I did a bit of research and discovered existing (although different) problems that people had experienced in Chrome (with the canvas element and this size image). So I tried using Firefox, and no errors!
Seems like the Chrome canvas element is far from perfect.
[Using Chrome Version 32.0.1700.77]
Edit: Also, setting the chrome://flags "Disable accelerated 2D canvas" makes it work in Chrome.