Add handlers to the image before the "new BitmapImage" line, like so:
this.Image.ImageOpened += ImageOpened;
this.Image.ImageFailed += ImageFailed;
Then, in the ImageOpened event, save to the WriteableBitmap:
private void ImageOpened(object sender, RoutedEventArgs e)
{
WriteableBitmap wb = new WriteableBitmap((BitmapImage)sender);
using (IsolatedStorageFile newIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
String tempJPEG = randomNumber.ToString();
IsolatedStorageFileStream fileStream = newIsolatedStorage.CreateFile(tempJPEG);
//fileStream.Close();
//fileStream.Flush();
BitmapImage image = new BitmapImage(new Uri("" + uri ));
image.CreateOptions = BitmapCreateOptions.None;
System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
}
}
You are currently attempting to save the image before it has loaded, hence the null pointer exception.