You almost have it--the one step you're missing is that you need to copy the fileStream (which is in memory) to the stream (connected to the file). Otherwise you're just throwing that encoded (and resized) memory stream away. Basically stick something like this between the flushAsync and the fileStream.close:
}).then(function () {
// Overwrite the contents of the file with the updated image stream.
fileStream.seek(0);
stream.seek(0);
stream.size = 0;
return Windows.Storage.Streams.RandomAccessStream.copyAsync(fileStream, stream);
Also remember to call stream.close in addition to fileStream.close. (I recommend using memStream and fileStream instead of fileStream and stream to be clear in your code.)
For a fully operational example, refer to scenario 2 of the Simple Imaging sample in the SDK.