Add function resolve_final_mime to better handle of mime conversion