title: PDF response is corrupted in Python 3 but works in Python 2
body: <p>I wrote a working application in python2.7 and Flask. One of the things it does is download a PDF invoice. It's working fine.</p>
  
  <p>Now I am doing a new app that also allows downloading a PDF invoice, but I am using Python3 this time. I can save the file to the server and get a perfectly working PDF, but if I try to send it to the browser, the resulting file is corrupted. </p>
  
  <p>Here is the download function:</p>
  
  <pre><code>@mod.route('/get_invoice/&lt;invoice_id&gt;')
  def get_invoice(invoice_id):
      invoice = Invoices.query.filter_by(id=invoice_id).all()
  
      pdf_generator = PDFInvoice(invoice)
      pdf = pdf_generator.new()
  
      response = make_response(pdf.output(dest='S'))
      response.headers['Content-Disposition'] = 'attachment; filename="invoice.pdf"'
      response.headers['Content-Type'] = 'application/pdf'
  
      return response
  </code></pre>
  
  <p>This is nearly identical to the working function in the older Python2.7 application.</p>
  
  <p>To expand, it is turning this (working PDF):</p>
  
  <pre><code>x�3R��2�35W(�r
  Q�w3T��30P^HISp^M^A�^X^[�^YZ*�^[^Z�^Y�*��(h�e^Vg�(�^V+$�(����e����奖h*�d��^@^@�v^T�
  </code></pre>
  
  <p>into this (corrupted PDF):</p>
  
  <pre><code>x^Ü3Rðâ2Ð35W(çr
  QÐw3T°Ô30P^HISp^M^A^É^X^[è^YZ*^Ø^[^Zê^Y^Û*^Ä¤(h^Äe^Vg^Ö(^Ô^V+$^Ö(^Ô^×^×ëe§æ^Õèå¥^Öh*^Äd^Áô^@^@øv^TÂ
  </code></pre>
  
  <p>The rest of the pdf's data is text strings, and they appear to be unchanged. So it seems to be an encoding issue someplace.</p>