Fix endswith error on Ubuntu (Python 3)

TypeError: endswith first arg must be bytes or a tuple of bytes, not str