fix s3 bug and add chunked output helper class