Fix PhantomJS crashes

* window.callPhantom is a experimental feature (aka rather unstable)
* use JSON-encoded string sent over console.log to communicate between browser's scope and phantomas