Fix buffer bounds

Improper set of buffer bounds was leading to "slice bounds out of range" runtime error.
Merge pull request #2 from striker2000/patch-1

Fix buffer bounds