Forgot to say this is the headless version on Linux I am using. Edit: I think I got to the bottom of this. I will post some code when I get to eventually solving my own problem.