quick fix for issue #65

At data.copy(), sourceEnd was sometimes bigger than data.length which caused the error. This makes sure sourceEnd does not exceed data.length. Fixed the problem for me.