Accept custom output filename as a parameter

Now accepts output filename as a parameter in both module and CLI version.
Added tests and updated readme as well.