Fix headers_sent issue in avatar helper.