encode into binary only if needed
Merge pull request #37 from rase-/fix/binary-only-if-needed

Encode into binary only if needed