implement writeToFrame