1."I was/am going to go out when you arrive..."means 你来的时候,我本来/正要出去了。
2."be going to do something" is just like the changing aspect of an action in Chinese,not the Prestent/past countinuous Tenses.
In Chinese ,when an action is going to change or to take place relatively soon,we use the pattern "要....了"to describe it.And this pattern mainly indicates that an action is going to take place in the future,but it can also show that an action was going to take place sometime in the past.
e.g.昨天飞机要起飞了,忽然下雨了。(The plane was setting out yesterday when it rained suddenly .)
e.g.上星期我要去旅行了,碰巧生病了。(I was going to travel when I was sick accidentally last week.)
e.g.快点,客人就要到了。(Hurry up,the guests are going to arrive.)
3.In Chinese,the aspect and the time of an action are not entirely expressed in one grammatical form.The state of an action has something to do with the time,but does not indicate the time.Thus adverbs and aspectual particles are often used to denote the different states of an action while the time of an action is mainly expressed by nouns ,adverbs or phrases denoting time.