Fix PDF export in Python3