Try to improve performance by using a read/write buffer instead of I/O.

The calls to fwrite/fread can be very expensive. GCC avoids this by using a
buffer to read and write from the file, thus limiting the number of fwrite/fread
calls.

<rdar://problem/13466086>