Better solution to fix 64 bit compiler warnings

Use the size_t data type where appropriate instead of casting.