Use finalize method in jinja2 to convert None values to empty strings

Fixes #4812
Merge branch 'issue_4812' into devel