Switch to Unix-style read/write functions

This commit also moves the code for handling reading and writing of
int32s into the generic functor.

Signed-off-by: John Else <john.else@citrix.com>