factory: Use codecs to encode/decode string

`'str'.encode` for `hex` and `base64` is deprecated in python3.
`'str'.decode` is the same.

We need to use codecs module to do this.

BUG=chromium:999876
TEST=make test
TEST=make lint

Change-Id: I7292154fac137b9d092fa693c9b6e79a20bcd1c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/1894784
Reviewed-by: Cheng Yueh <cyueh@chromium.org>
Commit-Queue: Yilin Yang <kerker@chromium.org>
Tested-by: Yilin Yang <kerker@chromium.org>
Auto-Submit: Yilin Yang <kerker@chromium.org>
diff --git a/py/utils/pygpt.py b/py/utils/pygpt.py
index cd4c0b5..c59d699 100755
--- a/py/utils/pygpt.py
+++ b/py/utils/pygpt.py
@@ -30,6 +30,7 @@
 
 import argparse
 import binascii
+import codecs
 import itertools
 import logging
 import os
@@ -861,7 +862,7 @@
           GPT.GetImageSize(image.name) // cls.DEFAULT_BLOCK_SIZE) - 1
       # Partition 0 must have have the fixed CHS with number of sectors
       # (calculated as legacy_sectors later).
-      part0 = ('00000200eeffffff01000000'.decode('hex') +
+      part0 = (codecs.decode('00000200eeffffff01000000', 'hex') +
                struct.pack('<I', legacy_sectors))
       # Partition 1~3 should be all zero.
       part1 = '\x00' * 16