Use BytesIO instead of StringIO

Use BytesIO for py3 compatibility. Also fixed the return values for
autocomplete module to return proper things.