cppcheck: reduce scope of variables
cppcheck: fix C-style casting
Merge pull request #17 from rdcastro/xpdf-fixes

Merge fixes from Rodrigo to fix too broad scope of variables in functions and to modernize the casts.