image preview - clean up, add error handler