There are two ways to export a .mi file for rendering with mental ray. The first method is to use the File > Export All option. The second method is to use the mi exporter from the command line.
To export a .mi file and render with mental ray using File > Export All
There are File Type Specific Options in the Export All Options window you can use to control file naming schemes and other details.
To export a .mi file using the command line
Render -r mi -rd "C:/images" -im "cmdTest" -of "tif" -s 10 -e 15 -b 1 -binary 0 -perframe 0 -exportPathNames "1111111111" -file "C:/temp/test.mi" mayascene.ma
The command above exports frames 10 to 15 (-s, -e, and -b flags), and exports one .mi file for the entire animation (-perframe flag). The exported .mi file is in ASCII format (-binary flag), with the path and filename C:/temp/test.mi. The .mi file uses the absolute path for its full name (-exportPathNames flag).
When the test.mi file is rendered with a Standalone renderer, the output image file is in tif format (-of flag) with the filename cmdTest (-im flag), and stored in the c:/images directory (-rd flag).