Cast to correct int types.

Fix compilation on Ubuntu 12.10 64bit.