Answer:
The work done is
and it is negative because the exterior is doing work on the gas.
The value of the heat flow is
and is directed out of the gas, as this is being cooled and compressed.
Explanation:
The work done by the gas can be written as

and all the data is given in the problem, so

is the work necessary to compress the gas in the cylinder, wich is negative because the exterior is doing work on the gas.
Now, from first law of thermodynamics, we have that

<em>where
is the internal energy difference,
is the calculated work, and
is the heat flow that we wish to know</em>, then

And the direction of the heat flow is outside of the gas, as it is being cooled and compressed.
Finally, it doesn't matter whether the gas is ideal or not, because we never use the Ideal Gas hypotesis, that
, and
is constant.