write output to file, and setup d3 template