added stdout; fixed encode length bug to unlimited