More robust writing/reading of integers.