private byte[] ConvertTextureData(AssetBase texture, string format)
        {
            m_log.DebugFormat("[GETTEXTURE]: Converting texture {0} to {1}", texture.ID, format);
            byte[] data = new byte[0];

            MemoryStream imgstream    = new MemoryStream();
            Bitmap       mTexture     = null;
            ManagedImage managedImage = null;
            Image        image        = null;

            try
            {
                // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data
                // Decode image to System.Drawing.Image
                if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null)
                {
                    // Save to bitmap
                    mTexture = new Bitmap(image);

                    using (EncoderParameters myEncoderParameters = new EncoderParameters())
                    {
                        myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95L);

                        // Save bitmap to stream
                        ImageCodecInfo codec = GetEncoderInfo("image/" + format);
                        if (codec != null)
                        {
                            mTexture.Save(imgstream, codec, myEncoderParameters);
                            // Write the stream to a byte array for output
                            data = imgstream.ToArray();
                        }
                        else
                        {
                            m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[GETTEXTURE]: Unable to convert texture {0} to {1}: {2}", texture.ID, format, e.Message);
            }
            finally
            {
                // Reclaim memory, these are unmanaged resources
                // If we encountered an exception, one or more of these will be null
                if (mTexture != null)
                {
                    mTexture.Dispose();
                }

                if (image != null)
                {
                    image.Dispose();
                }

                if (managedImage != null)
                {
                    managedImage.Clear();
                }

                if (imgstream != null)
                {
                    imgstream.Dispose();
                }
            }

            return(data);
        }