cast unicode data to string; skirts some unicode-related issues with cStringIO in 2.6
fallback to regular StringIO if cStringIO isn't available: more portable