Changed StringIO to BytesIO, fixing the TypeError that happens when concatenating the empty string with bytes.

Also initialize data in download to bytes rather than the empty string.