Multithresholding- OTSU method
I am sorry that I cannot see where your problem is. What do you mean by "how can I save the result?" If you want to use $oim$ in matlab, then it is already there. If you are interested in extracting one specific class, you can simply get the corresponding $n$th mask by calling $mask=(oim==n)$, which returns a binary mask with only the pixel belonging to the $n$th class marked as 1s. 

If you are going to save the classification result outside of matlab, for example a tif image, simply use imwrite function in matlab. Late you can read it via imread function.