Simplified Image import and fixed unicode error using io.StringIO