A heat engine undergoes a process in which its internal energy decreases by 400 J and it gives out 150 J of heat. During the process:
it does 250 J of work and its temperature falls
The internal energy of the system will decrease when the system does work and/or gives off heat. Since the heat given out is 150 J and the reduction in internal energy is 400 J, the work done by the engine is 400 -150 = 250 J.
When the internal energy is reduced, the system is cooled.