Update ImageToMatrix.java

Avoid NullPtrException