Correctly limit bounds in PutImageData to prevent segment fault

Addresses one part of #59.