fixing empty Mat case
Merge pull request #965 from apavlenko:fix_java_empty_mats