Use for loop instead of map when not iterating.

In PY3, map returns an opperator, so the funcion never gets called.
Correctly handle binascii.Error.
Fix unclosed file ResourceWarnings.
Check for bytes rather than str.
Use bytes literals instead of string literals.