I got the same error like the one you had. And I solved it by following the example on How to: Encode a JPEG for Windows Phone and Save to the Pictures Library on MSDN.
So your method should look as following
private void SaveAsPicture_Click(object sender, RoutedEventArgs e)
{
    WriteableBitmap bmp = new WriteableBitmap(MyUIElement, null);
    library.SavePicture("Certificate", stream);
    String tempJPEG = "TempJPEG";
    // Create a virtual store and file stream. Check for duplicate tempJPEG files.
    var myStore = IsolatedStorageFile.GetUserStoreForApplication();
    if (myStore.FileExists(tempJPEG))
    {
        myStore.DeleteFile(tempJPEG);
    }
    IsolatedStorageFileStream myFileStream = myStore.CreateFile(tempJPEG);
    bmp.SaveJpeg(myFileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
    myFileStream.Close();
    // Create a new stream from isolated storage, and save the JPEG file to the media library on Windows Phone.
    myFileStream = myStore.OpenFile(tempJPEG, FileMode.Open, FileAccess.Read);
    // Save the image to the camera roll or saved pictures album.
    MediaLibrary library = new MediaLibrary();
        // Save the image to the camera roll album.
    library.SavePicture("Certificate", myFileStream);
}