internal: rename "to_str" to "to_bytes" for clarity
internal: split code for Python 2/3 compatibility
Fix regression in v0.21.1, IndexEntry.path returns str

And str in Python 2 means bytes. Recall, we are supposed to give a
native experience to both Python 2 and 3 users.