gconv_strip: fix running under Python 3

Make sure we pass bytes everywhere with the ahocorasick module rather
than mixing strings and bytes.  Also turn the list of filenames back
into strings since we process them that way.

BUG=chromium:997354
TEST=running build_image with python3 chromite passes

Cq-Depend: chromium:1927612
Change-Id: I0696a29b65a5ebe6c29659f11c592b5482eb881c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1928611
Tested-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
diff --git a/scripts/gconv_strip.py b/scripts/gconv_strip.py
index baa17cb..f3b8f30 100644
--- a/scripts/gconv_strip.py
+++ b/scripts/gconv_strip.py
@@ -271,7 +271,8 @@
   symbols = ','.join(GCONV_SYMBOLS)
   cmd = ['scanelf', '--mount', '--quiet', '--recursive', '--format', '#s%F',
          '--symbol', symbols, opts.root]
-  result = cros_build_lib.run(cmd, redirect_stdout=True, print_cmd=False)
+  result = cros_build_lib.run(cmd, stdout=True, print_cmd=False,
+                              encoding='utf-8')
   files = set(result.output.splitlines())
   logging.debug('Symbols %s found on %d files.', symbols, len(files))
 
@@ -282,7 +283,7 @@
   # string, for example a binary with the string "DON'T DO IT\0" will match the
   # 'IT' charset. Empirical test on ChromeOS images suggests that only 4
   # charsets could fall in category.
-  strings = [s + '\0' for s in charsets]
+  strings = [s.encode('utf-8') + b'x\00' for s in charsets]
   logging.info('Will search for %d strings in %d files', len(strings),
                len(files))