Use safe xread/xwrite functions

This handles the case of piped input that may return a short block in
tar_block_read(), causing an error.