Buffer size and flags mask fix.
Merge pull request #255 from custodian/buffermask_fix

Buffer size and flags mask fix.