Unify file transfer code into module.

This makes the code cleaner, and was also necessary since Firefox does
not support FileReader() being called inside a web worker.