# How to externalize tikz/gnuplot in baposter

I want to include gnuplot graphs in a poster with the help of gnuplottex and its tikz terminal. In principle this is working (see MWE). However, because some of the graphs are quite complicated, I want to save compilation time by using tikz externalize feature. Unfortunately this is stopping with an emergency error. Has anyone an idea what is going on here and how to solve it?

\documentclass[a0paper,portrait,english]{baposter}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{gnuplot-lua-tikz}

%Uncomment these two lines to get the error. Make sure the folder gnuplottex is already present.
%\usetikzlibrary{external}
%\tikzexternalize[prefix=gnuplottex/]
\usepackage{gnuplottex}

\begin{document}
\background{
}
\begin{poster}{
}
{
% eye catcher
}
{
poster title
}
{
poster authors
}
{
%uni logo
}

\begin{posterbox}[name=box1,column=0,row=0,span=3]{Box 1}

Text
% \begin{fragile}
\begin{gnuplot}[terminal=tikz]
plot sin(x)
\end{gnuplot}
% \end{fragile}
Text
\end{posterbox}

\end{poster}
\end{document}