Fix 64 bit Windows compiler warnings

Mainly static_casts to downgrade from size_t to correct type. In all cases, it's not really possible for these to be that big so static_cast is ok.

This is in prep for move to 64 bit VS 2013 standard TeamCity builds.