Use cStringIO if possible.
Split up sendfile.
Constrain resizing.