Prevent compiler warning when compiling for 64 bit

When compiling for 64 bit size_t is a 64 bit data type but int is usually 32 bit.
Do the proper casts to avoid compiler warnings.