Add function to convert pyplot figure to pixels