Attempts to convert gif, tiff and bmp to png in pdf writer

Also fixes bug which caused pandoc generated latex to not compile, introduced in 211fe26