Add casts when converting pointer differences to integers

This fixes warnings when building with MSVC in 64 bit mode.
Merge pull request #1569 from mstorsjo/pointer-diff-cast

Add casts when converting pointer differences to integers
Merge remote-tracking branch 'upstream/master' into travis.osx