refactor image drawing and options parsing