In this paper, we introduce a new method to perform output error estimation and mesh adaptation in computational fluid dynamics (CFD) using machine-learning techniques. The error of interest is the functional output error induced by the numerical discretization, including the finite computational mesh and approximation order. Given the data of adaptive flow simulations guided by an adjoint-based error estimation method, a surrogate model is trained to predict the output error with only the low-fidelity solution as input. The goal is to generalize the error modeling knowledge from the simulation data at hand. The proposed method uses an encoder-decoder type convolutional neural network (CNN), supervised by both the adaptive error indicator field and the total output error to capture both the local and global features related to the numerical error. The feasibility of the proposed machine-learning approach for error prediction and mesh adaptation is demonstrated in a two-dimensional advection-diffusion problem. Both the output error and the localized adaptive indicators are well predicted by the trained CNN model, which is then used to drive the mesh adaptation as an alternative to the adjoint-based method. The good performance and relatively simple deployment encourage more study and development of the proposed method.