Replace file descriptor with a file stream in preparation for supporting
zipped files.
The API to miniz requires the use of file streams and since a file
descriptor can easily be extracted from a stream using `fileno` it's
much more convenient to use file streams everywhere.