add back import matplotlib matplotlib.use('Agg' to show image correctly