use MIME::Base64; # ... your GD code from above my $imageData = $image->png; # save $imageData to file with binmde... well you know that... open( my $PNG, ">", $imageFilename ) or die ...; binmode( $PNG ); print $PNG $imageData; close( $PNG ) or die ...; # convert $image to tk photo my $imageData64 = MIME::Base64::encode_base64( $imageData ); my $photo = $mw->Photo( -format => 'png', -data => $imageData64, ); # do something with $photo...