fix rendering issues due to incorrect page height computation

This was adapted from the following change in PhantomJS:
https://github.com/ariya/phantomjs/commit/24a9665c4d9d3e2690599e60b8699af679a45c2d