You can modify your code as below.
<pre>public byte[] convertToByte(Image imgControl)
{
if(img.Source!=null)
{
BitmapImage img = img.Source as bitmapImage;
using (MemoryStream ms = new MemoryStream())
{
WriteableBitmap btmap = new WriteableBitmap(img.PixelWidth, img.PixelHeight);
Extensions.SaveJpeg(btmap, ms, img.PixelWidth, img.PixelHeight, 0, 100);
ms.Seek(0, SeekOrigin.Begin);
return ms.ToArray();
};
}
}