Small enchancement to generate_pdf

Small enchancement to generate_pdf, now invalid latex compilation
results in raised exception, which simplifies launching pylatex in
batch mode (or from ipython notebook).