Merge pull request #1293 from dmatej/encoding

Fixed dependency on default encoding and work with streams