Changes needed for making it work on PhantomJS

This is a followup to the #15. Changes ported to the latest master branch. Tested that it does not break anything on Safari, Firefox, and Chrome, but it makes it work on PhantomJS 1.x.

In #15 it was suggested to create a fork, but for me it seems that those changes are no so drastic so that they would require a real fork to maintain. So I am creating a pull request to at least document it for others interested in running it on PhantomJS. Otherwise, one could see [this branch](https://github.com/peerlibrary/blob.js/tree/phantomjs) as such fork.