Thank you all for assistance. I was able to get the script working. What had to be done is what @r.sander mentioned. Change
#!/usr/bin/python
to
#!/usr/bin/env python3
Then update
(var[7:], value.decode('utf-8'))
to
(var[7:], value)
as decode is not necessary in py3.