Write and read binary data