prim changes to writing output

writing output to stdout now uses pandas dataframes and has been made
ready for python 3