Fixes #3. Use StringIO instead of a string for file buffer.