Refactor cv::Mat port to Java

- removed code multiplication for exception handling
- re-introduced dims() which got lost somehow in the previous version