Variable name overhaul

Prefix global variables with "g_".  This will help code maintenance (and
ease of moving to a new language, possibly).

Also, remove global x/y/z variables.  These must always be local from
this point forward.
Fix page count messaging when loading multipage images

Pages are base 0 in the code, but they should be displayed to the user
as base 1 (e.g. "Loading page 1 of 10" instead of "Loading page 0 of 9")