Add and use function that makes sure we work with strings (#1014220)
This is useful in many places where we are never sure if we get str or bytes and
we need/want to work with str objects.
Also remove one related (previously) unused import and obsolete comment
& needless encoding.