Only open X server once rather than open and close after every writeout.