Fix overflow issues on writing/reading integers
Merge pull request #11 from tonistiigi/overflow-issues

Fix overflow issues on writing/reading integers