Fix for #12

Snippet taken from https://github.com/lmccart/p5.js/issues/72