This fixes another bug with writing PDF files