support reading from and writing to a memory stream. To read from memory, pass content like this opendoc(None, file_content). To write to memory, pass the StringIO instance instead of a file name. See test cases.