Make python script v3 compatible

Closes #1709
Pull request reviewed by @neumino and @atnnn

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Additional python change

Review 1069 by @neumino
Merge pull request #1709 into next