Fix another protential issue with casting.

Another issue from #334 with the casting moved from the output of
min to it's inputs.

This is a non-issue on 64 bit machines, but if dolphin is compiled
on an OS with size_t == u32 (say ARM) then remainingSize could be
truncated.

Restored the casting to the original order before #334.
Merge pull request #624 from phire/fix-334-issue

Fix another protential issue with casting.