Factor out export code into a module

Fixes #57
Merge pull request #66 from eapache/export-refactor

Factor out export code into a module