Added a format param - defaults to png, but can also use pdf