Fix various 64 bit related warnings

Mostly printf() format strings and signed-unsigned comparisons.
Fixes the x86_64 build.