Fix and enhance image parser