moved dynimg functionality to javascript for better performance

Closes #771