Ok, so your logic should be like this:
public class ImageController
{
    [HttpGet]
    public virtual ActionResult Show(int id)
    {
        var byteArray = YourDatabaseAdapter.LoadImage(id);
        var mimeType = GetMimeType(fileName);
        return base.File(byteArray, mimeType, fileName);
    }
    private static string GetMimeType(string fileName)
    {
        var mimeType = "application/unknown";
        var extension = Path.GetExtension(fileName);
        if (extension != null)
        {
            var ext = extension.ToUpperInvariant();
            var regKey = Registry.ClassesRoot.OpenSubKey(ext);
            if (regKey != null && regKey.GetValue("Content Type") != null)
            {
                mimeType = regKey.GetValue("Content Type").ToString();
            }
        }
        return mimeType;
    }
}
The generic GetMimeType function sets your content-type in http header based on file extension taken from windows registry.
EDIT (for html content):
In case of passing html code to the content, jQuery .html(); invoked on external div with the content html should work as described in the reference:
$('.user').popover({ 
    html : true,
    content: function() {
      return $('#data-content-wrapper').html();
    }
});