Collection of fixes and enhacenments over memory and error management issues I've found latelly

Hi,

While diagnosing issue #1277, I've found a few more issues, ranging from memory disposal to missing warnings on some error conditions, etc. I've tried to make each fix/enhacenment as an independant commit to easy review.

Also, as I was not initially familiarized with the code, I expect comments and corrections from wkhtmltopdf's maintainer in order for this changes to be merged... So let this pull-request serve as a code review request.

Greets
Pablo