encode bitmap as png