Change several incorrect length modifiers in format strings

Several places throughout the code used %lu to print a size_t.
This works if size_t is long, but that might not be true e.g. on 32bit.
z is the proper length modifier for size_t.
This should fix a few warnings.