Fixed possible overflow in create_mask().
Renamed tbuf to buf in create_mask() to avoid confusion.
Merge pull request #641 from orium/possible-buffer-overflow-fix

Fixed possible overflow in create_mask().