Fix for issue #1

- fixed out of bounds read when width/stride
- added type cast to malloc