support StringIO as input

This is being used in Nyata from a branch, but would be nice if it were in the main line. Seems like it could be helpful for others.