PERF: Fixed decoding perf issue on py3 (GH5441)

closes #5441