Optimize file loading.
* Reduced number of canonical file queries
* Reduced number of byte array allocations
* Added buffering to streams
Merge pull request #1288 from charlesmunger/master

Optimize file loading.