Incorrect checksum computation on 64-bit systems

This is an alternative to #540 to fix #539.