you may try to output your data into the string buffer, and then write the buffer into the blob file:
import StringIO
stream = StringIO.StringIO()
writer.write( stream ) # write PDF content
# Open the file and write to it
with files.open(file_name, 'a') as f:
f.write( stream.getvalue() )
then finalize and do the usual stuff.