Replace print with logging call and improve error handling in pdflatex lib