Changed output_file() to read many bytes at a time

Instead of using getc() and putc(), reading one byte at a time (which is very slow), output_file() now reads many bytes at one time into a buffer and writes the buffer to the output file.