use cStringIO instead of temporary files