When you use the By() command, the platform returns a list, meaning that dist is actually a list with 2 values (dist[1] and dist[2] in this case). There may be more elegant ways to accomplish this, but one way would be to get a reference to the entire current window using Current Report ():
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt_dist = Distribution(
Nominal Distribution( Column( :age ), Horizontal Layout( 1 ), Vertical( 0 ) ),
By( :sex )
);
rpt = Current Report();
dist = rpt << get picture;
dist << Save Picture( "$DESKTOP\distribution_plot.png", "png" );