instead of \usepackage{tikz} and \usepackage{pgf}
make copy of main file as output.tex for tikz externalize