Terminal not recognizing imacro:// as protocol, thinks it's a pathname

Use

open /Applications/Firefox.app --args 'imacros://run/?m=macro.iim'

to prevent open from messing with the argument. Also quoting might help to stop the shell from stumbling over any special characters (not really required in this specific case).